<!--
 	* @author hemengxia
 积分兑换活动领取记录
-->
<template>
  <section class="integral-exchange-activity-record">
    <el-card class="box-card">
      <el-row>
        <el-col
          :span="6"
        >本日兑换积分：{{ statisticsInfo.countTodayIntegral || 0 }}</el-col>
        <el-col
          :span="6"
        >本周兑换积分：{{ statisticsInfo.countWeekIntegral || 0 }}</el-col>
        <el-col
          :span="6"
        >累计兑换积分：{{ statisticsInfo.countIntegral || 0 }}</el-col>
        <el-col :span="6">兑换人次:{{ statisticsInfo.countNum || 0 }}</el-col>
      </el-row>
      <el-row style="margin-top: 15px">
        <el-col
          :span="6"
        >本日兑换金额(元)：{{ statisticsInfo.countTodayMoney || 0 }}</el-col>
        <el-col
          :span="6"
        >本周兑换金额(元)：{{ statisticsInfo.countWeekMoney || 0 }}</el-col>
        <el-col
          :span="6"
        >累计兑换金额(元)：{{ statisticsInfo.countMoney || 0 }}</el-col>
        <el-col
          :span="6"
        >消费金额:{{ statisticsInfo.consumptionMoney || 0 }}</el-col>
      </el-row>
    </el-card>
    <el-collapse-transition>
      <section v-show="searchshow" class="main-search merge">
        <span class="svg-container">
          <svg-icon icon-class="search" />
        </span>
        <el-input
          v-model.trim="listQuery.userRealname"
          placeholder="输入姓名搜索"
          class="search-input"
          @keyup.enter.native="handleFilter"
        />
        <section class="search-btn">
          <el-button
            class="filter-item"
            type="primary"
            @click="handleFilter"
          >搜索</el-button>
          <el-button type="primary" @click="handleReset">重置</el-button>
          <span
            v-if="active !== '0'"
            class="search-more"
            @click="searchshow = !searchshow"
          >
            更多筛选条件
            <i class="el-icon-arrow-down" />
          </span>
        </section>
      </section>
    </el-collapse-transition>
    <el-collapse-transition>
      <section v-show="!searchshow" class="main-search separate">
        <section class="search-inner">
          <template v-if="active === '1'">
            <el-row>
              <el-col :span="8">
                <section class="search-inner-item">
                  <div class="item-label">姓名</div>
                  <el-input
                    v-model.trim="search.userRealname"
                    style="width: 90%"
                    class="filter-item"
                    placeholder="请输入姓名搜索"
                  />
                </section>
              </el-col>
              <el-col :span="8">
                <section class="search-inner-item">
                  <div class="item-label">领取最小金额</div>
                  <el-input
                    v-model.trim="search.minMoney"
                    style="width: 90%"
                    class="filter-item"
                    placeholder="请输入领取最小金额"
                  />
                </section>
              </el-col>
              <el-col :span="8">
                <section class="search-inner-item">
                  <div class="item-label">领取最大金额</div>
                  <el-input
                    v-model.trim="search.maxMoney"
                    style="width: 90%"
                    class="filter-item"
                    placeholder="请输入领取最大金额"
                  />
                </section>
              </el-col>
              <el-col :span="12">
                <section class="search-inner-item">
                  <div class="item-label">兑换时间</div>
                  <el-date-picker
                    v-model="search.time"
                    range-separator="至"
                    start-placeholder="开始日期"
                    end-placeholder="结束日期"
                    clearable
                    :style="{ width: '90%' }"
                    type="datetimerange"
                    format="yyyy-MM-dd HH:mm"
                    value-format="yyyy-MM-dd HH:mm:ss"
                  />
                </section>
              </el-col>
            </el-row>
          </template>
          <template v-if="active === '2'">
            <el-row>
              <el-col :span="8">
                <section class="search-inner-item">
                  <div class="item-label">姓名</div>
                  <el-input
                    v-model.trim="search.userRealname"
                    style="width: 90%"
                    class="filter-item"
                    placeholder="请输入姓名搜索"
                  />
                </section>
              </el-col>
              <el-col :span="8">
                <section class="search-inner-item">
                  <div class="item-label">商户名称</div>
                  <el-input
                    v-model.trim="search.merchantsName"
                    style="width: 90%"
                    class="filter-item"
                    placeholder="请输入商户名称搜索"
                  />
                </section>
              </el-col>
              <el-col :span="8">
                <section class="search-inner-item">
                  <div class="item-label">主订单号</div>
                  <el-input
                    v-model.trim="search.mainOrderNum"
                    style="width: 90%"
                    class="filter-item"
                    placeholder="请输入主订单号搜索"
                  />
                </section>
              </el-col>
              <el-col :span="8">
                <section class="search-inner-item">
                  <div class="item-label">订单号</div>
                  <el-input
                    v-model.trim="search.orderNum"
                    style="width: 90%"
                    class="filter-item"
                    placeholder="请输入订单号搜索"
                  />
                </section>
              </el-col>
              <el-col :span="8">
                <section class="search-inner-item">
                  <div class="item-label">主支付ID</div>
                  <el-input
                    v-model.trim="search.mainPayId"
                    style="width: 90%"
                    class="filter-item"
                    placeholder="请输入主支付ID搜索"
                  />
                </section>
              </el-col>
              <el-col :span="8">
                <section class="search-inner-item">
                  <div class="item-label">支付ID</div>
                  <el-input
                    v-model.trim="search.payId"
                    style="width: 90%"
                    class="filter-item"
                    placeholder="请输入支付ID搜索"
                  />
                </section>
              </el-col>
              <el-col :span="8">
                <section class="search-inner-item">
                  <div class="item-label">转账流水号</div>
                  <el-input
                    v-model.trim="search.runningNumber"
                    style="width: 90%"
                    class="filter-item"
                    placeholder="请输入转账流水号搜索"
                  />
                </section>
              </el-col>
              <el-col :span="8">
                <section class="search-inner-item">
                  <div class="item-label">订单状态</div>
                  <el-select
                    v-model="search.orderStatus"
                    placeholder="请选择状态搜索"
                    style="width: 80%"
                  >
                    <el-option label="待付款" value="1" />
                    <el-option label="付款中" value="2" />
                    <el-option label="付款成功" value="3" />
                    <el-option label="付款失败" value="4" />
                    <el-option label="付款异常" value="5" />
                    <el-option label="取消订单" value="6" />
                  </el-select>
                </section>
              </el-col>
            </el-row>
          </template>
          <template v-if="active === '3'">
            <el-row>
              <el-col :span="8">
                <section class="search-inner-item">
                  <div class="item-label">姓名</div>
                  <el-input
                    v-model.trim="search.userRealname"
                    style="width: 90%"
                    class="filter-item"
                    placeholder="请输入姓名搜索"
                  />
                </section>
              </el-col>
              <el-col :span="8">
                <section class="search-inner-item">
                  <div class="item-label">退款单号</div>
                  <el-input
                    v-model.trim="search.refundNo"
                    style="width: 90%"
                    class="filter-item"
                    placeholder="请输入退款单号搜索"
                  />
                </section>
              </el-col>
              <el-col :span="8">
                <section class="search-inner-item">
                  <div class="item-label">主订单号</div>
                  <el-input
                    v-model.trim="search.mainOrderNum"
                    style="width: 90%"
                    class="filter-item"
                    placeholder="请输入订单号搜索"
                  />
                </section>
              </el-col>
              <el-col :span="8">
                <section class="search-inner-item">
                  <div class="item-label">订单号</div>
                  <el-input
                    v-model.trim="search.orderNum"
                    style="width: 90%"
                    class="filter-item"
                    placeholder="请输入订单号搜索"
                  />
                </section>
              </el-col>
              <el-col :span="8">
                <section class="search-inner-item">
                  <div class="item-label">主支付ID</div>
                  <el-input
                    v-model.trim="search.mainPayId"
                    style="width: 90%"
                    class="filter-item"
                    placeholder="请输入主支付ID搜索"
                  />
                </section>
              </el-col>
              <el-col :span="8">
                <section class="search-inner-item">
                  <div class="item-label">支付ID</div>
                  <el-input
                    v-model.trim="search.payId"
                    style="width: 90%"
                    class="filter-item"
                    placeholder="请输入支付ID搜索"
                  />
                </section>
              </el-col>
            </el-row>
          </template>
        </section>
        <section class="search-btn">
          <el-button type="primary" @click="handleFilter">搜索</el-button>
          <el-button type="primary" @click="handleReset">重置</el-button>
          <span class="search-more" @click="searchshow = !searchshow">
            精简筛选条件
            <i class="el-icon-arrow-up" />
          </span>
        </section>
      </section>
    </el-collapse-transition>

    <section class="main-buttons">
      <section class="main-buttons-title">
        <span>统计</span>
      </section>
      <section class="main-buttons-btns">
        <el-button v-if="active === '4'" style="margin-left: 10px" @click="sendRefundFun">发起退款</el-button>
        <el-button
          v-if="active !== '4'"
          class="filter-item"
          style="margin-left: 10px"
          @click="handleExport"
        >导出
        </el-button>
        <el-button
          style="padding: 10px 30px"
          @click="handleCancel"
        >返回</el-button>
      </section>
    </section>

    <section class="main-tab">
      <el-tabs v-model="active" @tab-click="handleTabClick">
        <el-tab-pane
          v-for="item in types"
          :key="item.id"
          :label="item.name"
          :name="item.id"
        />
      </el-tabs>
    </section>
    <section class="main-table">
      <v-table
        :list="list"
        :tag="tableTag"
        :list-loading="listLoading"
        :filter-column="filtercolumn"
        :hover-arr="['balance']"
        :selection="false"
      >
        <el-table-column
          v-if="active === '0'"
          label="操作"
          fixed="right"
          align="center"
          min-width="100"
          class-name="small-padding fixed-width"
        >
          <template slot-scope="scope">
            <el-button
              type="text"
              size="mini"
              @click="handleDetail(scope.row, 'dh')"
            >兑换明细</el-button>
            <el-button
              type="text"
              size="mini"
              @click="handleDetail(scope.row, 'xf')"
            >消费明细</el-button>
          </template>
        </el-table-column>
        <el-table-column
          v-if="active === '2'"
          label="操作"
          fixed="right"
          align="center"
          min-width="100"
          class-name="small-padding fixed-width"
        >
          <template slot-scope="scope">
            <el-button
              v-if="tName === '惠福商城'"
              type="text"
              size="mini"
              @click="handleView(scope.row)"
            >详情
            </el-button>
            <el-button
              v-if="scope.row.orderStatus==='3'"
              type="text"
              size="mini"
              @click="handlePush(scope.row)"
            >推送
            </el-button>
          </template>
        </el-table-column>
        <el-table-column
          v-if="active === '3'"
          label="操作"
          fixed="right"
          align="center"
          min-width="100"
          class-name="small-padding fixed-width"
        >
          <template slot-scope="scope">
            <el-button
              type="text"
              size="mini"
              @click="handleView(scope.row)"
            >详情
            </el-button>
          </template>
        </el-table-column>
        <el-table-column
          v-if="active === '4'"
          label="操作"
          fixed="right"
          align="center"
          min-width="100"
          class-name="small-padding fixed-width"
        >
          <template slot-scope="scope">
            <el-button
              type="text"
              size="mini"
              @click="handleViewRefund(scope.row)"
            >查看详情
            </el-button>
          </template>
        </el-table-column>
      </v-table>
      <pagination
        v-show="total > 0"
        :total="total"
        :page.sync="listQuery.page"
        :limit.sync="listQuery.limit"
        @pagination="getList"
      />
    </section>

    <el-dialog
      v-el-drag-dialog
      :close-on-click-modal="false"
      :visible.sync="refundStatus"
      title="退款信息"
      center
      width="600px"
    >
      <p>
        <strong :style="{ color: '#333' }">下单时间：</strong>{{ obj.crtTime }}
      </p>
      <p>
        <strong :style="{ color: '#333' }">京东订单编号：</strong>{{ obj.orderNum }}
      </p>
      <p>
        <strong :style="{ color: '#333' }">订单金额：</strong>{{ obj.payMoney || 0 }}
      </p>
      <div>
        <strong :style="{ color: '#333' }">付款信息：</strong>
        <p :style="{ textIndent: '4em' }">
          <strong :style="{ color: '#333' }">微信扣款：</strong>{{ obj.wxPayMoney || 0 }}
        </p>
        <p :style="{ textIndent: '4em' }">
          <strong :style="{ color: '#333' }">福利子账户：</strong>{{ obj.childAccountPayMoney || 0 }}
        </p>
        <p :style="{ textIndent: '4em' }">
          <strong :style="{ color: '#333' }">自有资金：</strong>{{ obj.ordinaryAccountPayMoney || 0 }}
        </p>
      </div>
      <p>
        <strong :style="{ color: '#333' }">钱包付款流水号：</strong>{{ obj.runningNumber }}
      </p>
      <p>
        <strong :style="{ color: '#333' }">付款状态：</strong>{{ obj.orderStatus | filterStatus }}
      </p>
      <p>
        <strong :style="{ color: '#333' }">付款状态说明：</strong>{{ obj.errorReason || "无" }}
      </p>
      <p>
        <strong :style="{ color: '#333' }">可退款金额：</strong>{{ obj.refundMoney || 0 }}
      </p>
      <p
        v-show="!obj.refundMoney || obj.refundMoney == 0"
        :style="{ color: 'red' }"
      >
        *付款状态为{{ obj.orderStatus | filterStatus }}，无需退款。
      </p>
      <span slot="footer" class="dialog-footer">
        <el-button
          style="padding: 8px 30px"
          type="primary"
          @click="refundStatus = false"
        >取消</el-button>
        <el-button
          v-if="obj.orderStatus === '3'"
          style="padding: 8px 30px"
          type="primary"
          @click="handleConfirmRefund()"
        >退款</el-button>
      </span>
    </el-dialog>

    <el-dialog
      v-el-drag-dialog
      title="查看"
      :visible.sync="dialogVisible"
      width="50%"
    >
      <el-form label-position="left" size="mini">
        <el-row v-if="active === '2'">
          <el-col :span="12">
            <el-form-item label="活动类型：">
              <span>{{ view.activityType | typeFilter }}</span>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="活动名称：">
              <span>{{ view.activityName }}</span>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="主订单号：">
              <span>{{ view.mainOrderNum || "" }}</span>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="订单号：">
              <span>{{ view.orderNum || "" }}</span>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="主支付ID：">
              <span>{{ view.mainPayId }}</span>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="支付ID：">
              <span>{{ view.payId }}</span>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="用户姓名：">
              <span>{{ view.userRealname || "" }}</span>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="用户手机号：">
              <span>{{ view.phoneNumber | jiemi }}</span>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="用户身份证号：">
              <span>{{ view.userIdnumber | jiemi }}</span>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="部门：">
              <span>{{ view.deptName || "" }}</span>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="转账流水号：">
              <span>{{ view.runningNumber }}</span>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="订单金额：">
              <span>{{ view.orderPriceValue || "" }}</span>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="运费：">
              <span>{{ view.freightValue || "包邮" }}</span>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="支付金额：">
              <span>{{ view.payMoneyValue || "" }}</span>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="付款时间：">
              <span>{{ view.payTime || "" }}</span>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="订单状态：">
              <span>{{ view.orderStatusName || "" }}</span>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="付款账户：" />
            <section
              v-for="(item, index) in view.payAccount"
              :key="index"
              class="pay-item"
            >
              <span class="pay-label">账户类型：</span>
              <span class="pay-content">{{ item.subAccountType }}</span>
              <span class="pay-label">支付金额：</span>
              <span class="pay-content">{{ item.payMoney }}</span>
            </section>
          </el-col>
        </el-row>
        <el-row v-if="active === '3'">
          <el-col :span="12">
            <el-form-item label="活动类型：">
              <span>{{ view.activityType | typeFilter }}</span>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="活动名称：">
              <span>{{ view.activityName }}</span>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="退款单号：">
              <span>{{ view.refundNum || "" }}</span>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="退款人：">
              <span>{{ view.userRealname || "" }}</span>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="退款人所在部门：">
              <span>{{ view.deptName || "" }}</span>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="退款人手机号">
              <span>{{ view.phoneNumber | jiemi }}</span>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="退款人证件号：">
              <span>{{ view.userIdnumber | jiemi }}</span>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="主订单号：">
              <span>{{ view.mainOrderNum }}</span>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="订单号：">
              <span>{{ view.orderNum }}</span>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="主支付ID：">
              <span>{{ view.mainPayId }}</span>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="支付ID：">
              <span>{{ view.payId }}</span>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="订单金额：">
              <span>{{ view.orderPriceValue || "未知" }}</span>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="退款金额：">
              <span>{{ view.refundMoneyValue || "未知" }}</span>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="退款原因：">
              <span>{{ view.refundReason || "无" }}</span>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="退款时间：">
              <span>{{ view.refundTime || "" }}</span>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="退款说明：">
              <span>{{ view.refundDesc || "无" }}</span>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="退款账户：" />
            <section
              v-for="(item, index) in view.refundInfo"
              :key="index"
              class="pay-item"
            >
              <span class="pay-label">账户类型：</span>
              <span class="pay-content">{{ item.subAcntTp }}</span>
              <span class="pay-label">退款金额：</span>
              <span class="pay-content">{{ item.payAmt }}</span>
            </section>
          </el-col>
        </el-row>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button
          type="primary"
          @click="dialogVisible = false"
        >关 闭</el-button>
      </span>
    </el-dialog>
    <!-- 选择入金账户 -->
    <el-dialog
      v-el-drag-dialog
      :destroy-on-close="true"
      :close-on-click-modal="false"
      width="800px"
      title="选择入金账户"
      center
      :visible.sync="innerVisible"
      append-to-body
    >
      <el-table
        v-loading="dlistLoading"
        style="height: 400px"
        :data="inAccount"
      >
        <el-table-column property="name" label="账户名称" />
        <el-table-column
          property="accountNumber"
          :formatter="getNumber"
          label="账户号"
        />
        <el-table-column label="操作" width="50">
          <template slot-scope="scope">
            <el-button
              type="text"
              size="small"
              @click="chooseOne(scope.row)"
            >选择</el-button>
          </template>
        </el-table-column>
      </el-table>
      <pagination
        v-show="dtotal > 0"
        :total="dtotal"
        :page.sync="dquery.page"
        :limit.sync="dquery.pageSize"
        @pagination="getAccFun()"
      />
    </el-dialog>
  </section>
</template>
<script>
import Pagination from '@/components/Pagination'
import VTable from '@/components/Table'
import {
  getDictByCode,
  queryRecord,
  queryStatistics,
  exportFile,
  refund,
  exporthfOrderMask,
  exporthfOrderNoMask,
  queryRefundDetail,
  queryOrderDetail,
  getAcc,
  getInAcc,
  exporthfRefundMask,
  exporthfRefundNoMask,
  dataPush,
  exportJdOrderMask,
  exportJdOrderNoMask
} from '../api/index'
import { exportSign } from '@/utils/fileImportOrExportSign'
import permission from '@/directive/permission/index.js'
import elDragDialog from '@/directive/el-drag-dialog'
import CryptoJS from '@/utils/aesJiaJM'
import { exportCheck } from '@/utils/sensitiveInfoExportCheck'
export default {
  name: 'IntegralExchangeActivityRecord',
  components: { Pagination, VTable },
  directives: { permission, elDragDialog },
  filters: {
    filterStatus(val) {
      switch (val) {
        case '1':
          return '待付款'
        case '2':
          return '付款中'
        case '3':
          return '付款成功'
        case '4':
          return '取消订单'
      }
    },
    jiemi(str) {
      return str ? CryptoJS.$aesJieM(str) : ''
    },
    formatDate(t) {
      return t && t.length > 0 ? t.substring(0, 10) : ''
    },
    typeFilter(t) {
      return t && t === '1' ? '外部积分兑换活动' : '定向福利'
    }
  },
  data() {
    return {
      active: '0',
      tableTag: 'integralExchangeRecord',
      types: [
        {
          name: '人员统计',
          id: '0',
          tag: 'integralExchangeRecord'
        },
        {
          name: '兑换记录',
          id: '1',
          tag: 'integralExchangeRecordDetail'
        },
        {
          name: '订单记录',
          id: '2',
          tag: 'hfconfigOrderDetail'
        }

      ],
      listQuery: {
        page: 1,
        limit: 10,
        userRealname: ''
      },
      searchshow: true,
      search: {
        userRealname: '',
        minMoney: '',
        maxMoney: '',
        time: [],
        orderNum: '',
        runningNumber: '',
        orderStatus: '',
        refundNo: '',
        enterpriseName: '',
        mainOrderNum: '',
        mainPayId: '',
        payId: '',
        merchantsName: ''
      },
      list: [],
      total: 0,
      listLoading: false,
      dict: {
        HBHDLQZT: [],
        HBHDGQZT: []
      },
      viewURL: '/API-DOCUMENT/document/file/download?id=',
      link: '/survey?i=',
      previewStatus: false,
      obj: {},
      id: '',
      statisticsInfo: {},
      refundStatus: false,
      dialogVisible: false,
      view: {},
      innerVisible: false,
      dlistLoading: false,
      inAccount: [],
      dtotal: 0,
      dquery: {
        page: 1,
        pageSize: 10
      },
      tName: ''
    }
  },
  created() {
    this.id = this.$route.query.i
    this.tName = this.$route.query.t
    if (this.tName === '惠福商城') {
      this.types.push({
        name: '订单退款记录',
        id: '3',
        tag: 'hfrefundList'
      })
      this.types.push({
        name: '余额退款记录',
        id: '4',
        tag: 'refundmentRecord'
      })
    } else {
      // 京东的数据
      this.types[2].tag = 'jdconfigOrderDetail'
    }
    this.getList()
    this.queryStatistics()
  },
  methods: {
    sendRefundFun() {
      if (!this.statisticsInfo.balance || this.statisticsInfo.balance === 0) {
        this.$message.error('账户没有可退余额，不能发起退款')
        return
      } else {
        this.getAccFun()
      }
    },
    getAccFun() {
      this.dlistLoading = true
      var query = {
        page: this.dquery.page,
        pageSize: this.dquery.pageSize,
        accountStatus: 'ZHZT01',
        accountType: 'INCOME'
      }
      return new Promise((resolve, reject) => {
        getInAcc(query)
          .then((response) => {
            if (response.data.code == '200') {
              this.inAccount = response.data.data.rows || []
              this.dtotal = response.data.data.total
              this.dlistLoading = false
              if (this.dtotal == 0) {
                this.$message.error('当前未配置收款账户，请先配置收款账户。')
              } else if (this.dtotal == 1) {
                this.chooseOne(this.inAccount[0])
              } else {
                this.innerVisible = true
              }
            } else {
              this.$message.error(response.data.msg || '入金账户获取失败')
            }
          })
          .catch((error) => {
            reject(error)
            this.dlistLoading = false
          })
      })
    },
    getNumber(row, col) {
      return row['accountNumber']
        ? CryptoJS.$aesJieM(row['accountNumber'])
        : ''
    },
    chooseOne(row) {
      this.insertRefund(row)
    },
    insertRefund(row) {
      const jm = CryptoJS.$aesJieM(row['accountNumber'])
      refund({
        welfareId: this.$route.query.i,
        accountNumber: CryptoJS.$aesJiaM(jm)
      })
        .then((response) => {
          if (response.data.code == '200') {
            this.getList()
          } else {
            this.$message.error(response.data.msg || '入金账户获取失败')
          }
        })
        .catch((error) => {})
    },
    handleRefund(row) {
      this.obj = Object.assign({}, row, row.jdOrderVO)
      this.$set(this.obj, 'parentId', row.id)
      this.refundStatus = true
    },
    handleConfirmRefund() {
      this.$confirm('确定要退款吗?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      })
        .then(() => {
          const loading = this.$loading({
            lock: true,
            text: '请稍后',
            spinner: 'el-icon-loading',
            background: 'rgba(0, 0, 0, 0.3)'
          })
          return new Promise((resolve, reject) => {
            refund({ id: this.obj.parentId })
              .then(() => {
                loading.close()
                this.$message({
                  title: '成功',
                  message: '退款成功',
                  type: 'success',
                  duration: 2000
                })
                this.refundStatus = false
                this.getList()
              })
              .catch((error) => {
                loading.close()
                reject(error)
              })
          })
        })
        .catch(() => {})
    },
    /**
     * 选项卡切换
     */
    handleTabClick(tab, event) {
      if (tab.index === '0') {
        this.searchshow = true
      }
      this.tableTag = this.types[tab.index].tag
      this.listQuery.page = 1
      this.getList()
    },
    /**
     * 查看详情
     * */
    handleDetail(row, t) {
      this.$router.push({
        path: this.$filterPath('recordDetail'),
        query: { i: this.id, userId: row.userId, t: t }
      })
    },

    /**
     * 导出
     * @param row
     */
    handleExport() {
      let query = {}
      if (this.searchshow) {
        query['userRealname'] = this.listQuery.userRealname
      } else {
        query['userRealname'] = this.search.userRealname
        if (this.active === '1') {
          query['minMoney'] = this.search.minMoney
          query['maxMoney'] = this.search.maxMoney
          query['startTime'] =
            this.search.time && this.search.time.length > 0
              ? this.search.time[0]
              : ''
          query['endTime'] =
            this.search.time && this.search.time.length > 0
              ? this.search.time[1]
              : ''
        } else if (this.active === '2') {
          query['orderNum'] = this.search.orderNum
          query['runningNumber'] = this.search.runningNumber
          query['orderStatus'] = this.search.orderStatus
          query['userRealname'] = this.search.userRealname
          query['mainOrderNum'] = this.search.mainOrderNum
          query['mainPayId'] = this.search.mainPayId
          query['payId'] = this.search.payId
          query['merchantsName'] = this.search.merchantsName
        } else if (this.active === '3') {
          query['refundNum'] = this.search.refundNo
          query['userRealname'] = this.search.userRealname
          query['mainOrderNum'] = this.search.mainOrderNum
          query['mainPayId'] = this.search.mainPayId
          query['payId'] = this.search.payId
          query['orderNum'] = this.search.orderNum
        }
      }
      let url = ''
      let fileName = ''
      if (this.active === '0') {
        query.activityId = this.id
        fileName = '人员统计.xlsx'
        url = '/backend/exchangeActivity/activityStatisticsUsersExport'
      } else if (this.active === '1') {
        query.activityId = this.id
        fileName = '兑换记录.xlsx'
        url = '/backend/exchangeActivity/activityStatisticsUserExport'
      }
      query.activityId = this.id
      if (this.active === '2' && this.tName === '京东商城') {
        query['giveId'] = this.id
      }
      query = exportSign(query).obj
      if (this.active === '2') {
        fileName = '订单记录.xlsx'
        if (this.tName === '京东商城') {
          exportCheck(
            'WELFARE_PAYMENT_INTEGRALCONFIG',
            this.id,
            exportJdOrderMask,
            exportJdOrderNoMask,
            query,
            fileName
          )
        } else {
          exportCheck(
            'WELFARE_PAYMENT_INTEGRALCONFIG',
            this.id,
            exporthfOrderMask,
            exporthfOrderNoMask,
            query,
            fileName
          )
        }
      } else if (this.active === '3') {
        fileName = '订单退款记录.xlsx'
        exportCheck(
          'WELFARE_PAYMENT_INTEGRALCONFIG',
          this.id,
          exporthfRefundMask,
          exporthfRefundNoMask,
          query,
          fileName
        )
      } else {
        const loading = this.$loading({
          lock: true,
          text: '请稍后',
          spinner: 'el-icon-loading',
          background: 'rgba(0, 0, 0, 0.3)'
        })
        exportFile(query, url)
          .then((res) => {
            loading.close()
            const content = res.data
            const blob = new Blob([content])
            if ('download' in document.createElement('a')) {
              const elink = document.createElement('a')
              elink.download = fileName
              elink.style.display = 'none'
              elink.href = URL.createObjectURL(blob)
              document.body.appendChild(elink)
              elink.click()
              URL.revokeObjectURL(elink.href) // 释放URL 对象
              document.body.removeChild(elink)
            } else {
              navigator.msSaveBlob(blob, fileName)
            }
          })
          .catch(() => {
            // this.$message.error()
            loading.close()
          })
      }
    },

    handleCancel() {
      this.$router.back()
    },
    getDict(code) {
      return new Promise((resolve, reject) => {
        getDictByCode(code)
          .then((response) => {
            this.dict[code] = response.data.data[0].list
            resolve()
          })
          .catch((error) => {
            reject(error)
          })
      })
    },
    filtercolumn(scope, item) {
      if (item === 'coverImgId') {
        return this.viewURL + scope.row[item]
      } else if (item === 'phoneNumber') {
        return CryptoJS.$aesJieM(scope.row[item])
      } else if (item === 'activityType') {
        return scope.row[item] && scope.row[item] === '1'
          ? '外部积分兑换活动'
          : '定向福利'
      } else {
        return scope.row[item]
      }
    },

    handleReset() {
      this.listQuery.page = 1
      this.listQuery.userRealname = ''
      for (const i in this.search) {
        if (this.search['' + i + ''] instanceof Array) {
          this.search['' + i + ''] = []
        } else {
          this.search['' + i + ''] = ''
        }
      }
      this.getList()
    },

    handleFilter() {
      this.listQuery.page = 1
      this.list = []
      this.getList()
    },

    getList(obj) {
      this.listLoading = true
      var query = {
        page: obj ? obj.page : this.listQuery.page,
        pageSize: obj ? obj.limit : this.listQuery.limit
      }
      if (this.searchshow) {
        query['userRealname'] = this.listQuery.userRealname
      } else {
        query['userRealname'] = this.search.userRealname
        if (this.active === '1') {
          query['minMoney'] = this.search.minMoney
          query['maxMoney'] = this.search.maxMoney
          query['startTime'] =
            this.search.time && this.search.time.length > 0
              ? this.search.time[0]
              : ''
          query['endTime'] =
            this.search.time && this.search.time.length > 0
              ? this.search.time[1]
              : ''
        } else if (this.active === '2') {
          query['orderNum'] = this.search.orderNum
          query['runningNumber'] = this.search.runningNumber
          query['orderStatus'] = this.search.orderStatus
          query['userRealname'] = this.search.userRealname
          query['mainOrderNum'] = this.search.mainOrderNum
          query['mainPayId'] = this.search.mainPayId
          query['payId'] = this.search.payId
          query['merchantsName'] = this.search.merchantsName
        } else if (this.active === '3') {
          query['refundNum'] = this.search.refundNo
          query['userRealname'] = this.search.userRealname
          query['mainOrderNum'] = this.search.mainOrderNum
          query['mainPayId'] = this.search.mainPayId
          query['payId'] = this.search.payId
          query['orderNum'] = this.search.orderNum
        }
      }
      let url = ''
      if (this.active === '0') {
        query['activityId'] = this.id
        url = '/backend/exchangeActivity/getActivityStatisticsUsers'
      } else if (this.active === '1') {
        query['activityId'] = this.id
        url = '/backend/exchangeActivity/getActivityStatisticsUser'
      } else if (this.active === '2') {
        if (this.tName === '惠福商城') {
          url = '/backend/huifuOrder/queryPage'
          query['activityId'] = this.id
        } else {
          url = '/backend/jdActivity/queryPageJdOrder'
          query['giveId'] = this.id
        }
      } else if (this.active === '3') {
        query['activityId'] = this.id
        // query['giveId'] = 'ffc9be62d723434caac4e7b0b92c0f44'
        url = '/backend/huifuOrderRefund/queryPage'
      } else if (this.active === '4') {
        url = '/backend/refundmentRecord/queryPage'
        query['welfareId'] = this.id
      }
      return new Promise((resolve, reject) => {
        queryRecord(query, url)
          .then((response) => {
            this.list = response.data.data.rows
            this.total = response.data.data.total
            this.listLoading = false
          })
          .catch((error) => {
            reject(error)
            this.listLoading = false
          })
      })
    },

    /**
     *
     * @returns {Promise<unknown>}
     */
    queryStatistics() {
      var query = {
        activityId: this.id
      }
      return new Promise((resolve, reject) => {
        queryStatistics(query)
          .then((response) => {
            this.statisticsInfo = response.data.data || {}
          })
          .catch((error) => {
            reject(error)
          })
      })
    },
    handleViewRefund(row) {
      this.$router.push({
        path: this.$filterPath('refundInfo'),
        query: { id: row.id }
      })
    },
    handleView(row) {
      const loading = this.$loading({
        lock: true,
        text: '请稍后',
        spinner: 'el-icon-loading',
        background: 'rgba(0, 0, 0, 0.3)'
      })
      if (this.active === '3') {
        queryRefundDetail({
          id: row.id
        })
          .then((res) => {
            loading.close()
            if (res.data.code === '200') {
              this.view = res.data.data
              if (this.view.refundInfo) {
                this.view.refundInfo = JSON.parse(this.view.refundInfo)
              }
              this.dialogVisible = true
            }
          })
          .catch((err) => {
            console.log(err)
            loading.close()
          })
      } else {
        loading.close()
        /* queryOrderDetail({
          id: row.id
        }).then((res) => {
          if (res.data.code === '200') {
            this.view = res.data.data
            this.dialogVisible = true
          }
        })*/
        this.view = Object.assign({}, row)
        this.dialogVisible = true
      }
    },
    handlePush(row) {
      const loading = this.$loading({
        lock: true,
        text: '请稍后',
        spinner: 'el-icon-loading',
        background: 'rgba(0, 0, 0, 0.3)'
      })
      dataPush({ payId: row.payId }).then(res => {
        loading.close()
        this.$message({
          type: 'success',
          message: '操作成功'
        })
      }).catch(err => {
        console.log(err)
        loading.close()
      })
    }
  }
}
</script>
<style lang="scss">
@import "@/styles/mixin.scss";

.integral-exchange-activity-record {
  padding: 0 10px 10px;

  .box-card {
    margin: 10px;
  }

  .main-tab {
    width: 100%;
    margin-top: 10px;
    padding: 0 10px;
    background-color: #fff;
    display: flex;
    border-radius: 4px;

    .el-tabs__nav-wrap::after {
      display: none;
    }

    .el-tabs__header {
      margin: 0;
    }
  }

  .main-search {
    background-color: #fff;
    padding: 0 10px;

    .svg-container {
      padding: 0 5px 0 10px;
      color: #bfced6;
      vertical-align: middle;
      display: inline-block;
    }

    .search-input {
      width: 60%;
      position: relative;

      &:after {
        content: "";
        position: absolute;
        left: -25px;
        right: 0;
        bottom: 8px;
        height: 1px;
        background: rgba(226, 227, 232, 1);
      }

      input {
        outline: none;
        background: transparent;
        border: none;
        outline: medium;
        padding: 0;

        &:focus {
          outline: none;
          background-color: transparent;
        }
      }
    }

    .search-btn {
      display: inline-block;
      float: right;

      .el-button.is-round {
        padding: 10px 30px;
        margin-right: 34px;
      }

      .search-more {
        font-size: 14px;
        font-weight: 500;
        @include font-color($mainColor);
        cursor: pointer;
        margin-left: 10px;
      }
    }

    &.merge {
      height: 50px;
      line-height: 50px;
    }

    &.separate {
      .search-inner {
        padding-top: 10px;

        .search-inner-item {
          .item-label {
            height: 30px;
            line-height: 30px;
            font-size: 14px;
            color: #a6a6a6;
            font-weight: 400;
          }

          .el-input {
            position: relative;

            &.el-date-editor input {
              padding-left: 30px;
            }

            .el-input__inner {
              border: none;
              padding: 0;
            }

            &:after {
              content: "";
              height: 1px;
              background-color: #e2e3e8;
              position: absolute;
              left: 0;
              right: 0;
              bottom: 0;
            }
          }
        }
      }

      .search-btn {
        text-align: center;
        display: block;
        float: none;
        height: 56px;
        line-height: 56px;
      }
    }
  }

  .main-buttons {
    display: flex;
    line-height: 36px;
    margin-top: 10px;

    .main-buttons-title {
      flex: 1;
      height: 36px;
      line-height: 36px;
      font-size: 16px;
      font-weight: bold;
      color: rgba(51, 51, 51, 1);
    }
  }
  .el-dialog__footer {
    text-align: center;
  }
  .pay-item {
    padding-top: 5px;
    padding-left: 100px;
    .pay-label {
      font-weight: 600;
    }
    .pay-content {
      margin-right: 50px;
    }
  }
}
</style>
